# ----------------------------------------------------------------------------
#   ERSuppressF1.rb  Suppress the F1 key
# ----------------------------------------------------------------------------
# The F1 key is too close to my laptop ESC key. I'm suppressing it
# to stop the Help html from constantly popping up over my view.

require "sketchup.rb"
require "EventRelay.dll"

# ----------------------------------------------------------------------------
class ERSuppressF1 < EventRelay
# ----------------------------------------------------------------------------
    # Virtual key code
    VK_F1     = 112 #F1 key

    SUPPRESS = true
    ALLOW = false

    # ----------------------------------
    #    initialize
    # ----------------------------------
    def initialize
        super
        #-SendKeyMacro("!WR") #// Open Ruby Console
    end
    # ----------------------------------
    #    OnKeyDown
    # ----------------------------------
    def OnKeyDown(key,repeat,flags)
        #- puts "OnKeyDown key:#{key} repeat:#{repeat} flags:#{flags}"
        #- vk_key, keyMacro = GetKeyInfo(key, flags)
        #- puts("KeyInfo: vk_key:#{vk_key} keyMacro:{#{keyMacro}}")

        # Kill F1 key
        if (key == VK_F1) #Kill Help key
            return SUPPRESS
        end

        return ALLOW
    end

end # class ERSuppressF1
# ----------------------------------------------------------------------------

unless file_loaded?("ERSuppressF1.rb")
    myERSuppressF1 = ERSuppressF1.new
    file_loaded "ERSuppressF1.rb"
end

